import { FormControl, NG_VALIDATORS } from '@angular/forms';
import { Directive} from '@angular/core';

export function validateMobile(c: FormControl) {
    let MOBILE_REGEXP = /^1[0-9]{10,10}$/;
    return MOBILE_REGEXP.test(c.value) ? null : {
        validateMobile: {valid: false}
    }
}

export function validateMoney(c: FormControl) {
    console.log("bbbbbbbb");
    let REGEXP = /^(([1-9]\d{0,9})|0)(\.\d{1,2})?$/;
    return REGEXP.test(c.value) ? null :　{
        validateMoney: {valid: false}
    }
}

@Directive({
    selector: '[validateMobile][ngModel]',
    providers: [
        { provide: NG_VALIDATORS, useValue: validateMobile, multi: true }
    ]
})

@Directive({
    selector: '[validateMoney][ngModel]',
    providers: [
        { provide: NG_VALIDATORS, useValue: validateMoney, multi: true }
    ]
})

export class Volidator {}
